﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MxTol.API.Helpers
{
    /// <summary>
    /// http 请求参数获取帮助类
    /// </summary>
    public class WebQueryHelper
    {
        
        /// <summary>
        /// 获取地址栏参数值(Get请求)
        /// </summary>
        /// <param name="key">参数名称</param>
        /// <returns>不存在则返回空字符串</returns>
        public static string QueryString(string key)
        {
            return HttpContext.Current.Request.QueryString[key] == null ? "" : HttpContext.Current.Request.QueryString[key].Trim();
        }

        /// <summary>
        /// 从请求主体部分获取参数值(Post请求)
        /// </summary>
        /// <param name="key">参数名称</param>
        /// <returns>不存在则返回空字符串</returns>
        public static string QueryFormString(string key)
        {
            return HttpContext.Current.Request.Form[key] == null ? "" : HttpContext.Current.Request.Form[key].Trim();
        }
    }
}